Skip to content

[DYN-8894] When groups expand, auto layout relocates adjacent groups/nodes to avoid overlaps#16333

Merged
zeusongit merged 16 commits into
DynamoDS:masterfrom
ivaylo-matov:DYN-8894-GroupAutoLayout_250624_
Jul 9, 2025
Merged

[DYN-8894] When groups expand, auto layout relocates adjacent groups/nodes to avoid overlaps#16333
zeusongit merged 16 commits into
DynamoDS:masterfrom
ivaylo-matov:DYN-8894-GroupAutoLayout_250624_

Conversation

@ivaylo-matov

Copy link
Copy Markdown
Contributor

Purpose

This PR aims to address DYN-8894.

New logic to relocate groups, notes, nodes and their associated connector pins if they overlap with expanding group. This also applies when optional inports or unconnected outports are expanded.

Please note: This PR is built on top of #16302, so most of the changes included here are already present in that branch.

DYN-8894-proposed

Declarations

Check these if you believe they are true

  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB
  • This PR introduces new feature code involve network connecting and is tested with no-network mode.

Release Notes

New logic to relocate groups, notes, nodes and their associated connector pins if they overlap with expanding group. This also applies when optional inports or unconnected outports are expanded.

Reviewers

@DynamoDS/eidos
@jasonstratton

FYIs

@achintyabhat
@dnenov

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-8894

@QilongTang QilongTang requested a review from Copilot July 1, 2025 13:44
@QilongTang

Copy link
Copy Markdown
Contributor

Thank you @ivaylo-matov, @jasonstratton is out this week so PR review could be delayed. @reddyashish @zeusongit Would you help if you have time this week?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances group collapse behavior by allowing optional input and unconnected output ports to be hidden, adds a “collapse to minimal size” option, and implements auto-layout of adjacent elements when a group expands.

  • Preferences panel UI updated with toggles for optional/unconnected ports and minimal-size collapse
  • Annotation view and view-model extended for proxy port controls, port‐toggle styling, and dynamic repositioning
  • Serialization, model classes, and preference settings updated to persist and respect new collapse state

Reviewed Changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml Added rows and toggle UI for port collapse and min‐size
src/DynamoCoreWpf/Views/Core/AnnotationView.xaml.cs Refactored collapsed layout, removed old bindings, added port‐toggle grids
src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs Bound new preference properties
src/DynamoCoreWpf/ViewModels/Core/Converters/SerializationConverters.cs Wrote new collapse flags to JSON
src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs Added port collections, proxy creation, layout/update logic
src/DynamoCoreWpf/UI/Converters.cs Enhanced color converter for toggle styling; new angle converter
src/DynamoCoreCore/Graph/Annotations/AnnotationModel.cs Introduced serialization properties, refactored boundary calculations
src/DynamoCore/Configuration/PreferenceSettings.cs Default values for new collapse preferences
Files not reviewed (1)
  • src/DynamoCoreWpf/Properties/Resources.Designer.cs: Language not supported
Comments suppressed due to low confidence (5)

src/DynamoCoreWpf/Views/Core/AnnotationView.xaml.cs:1489

  • Removing the width and height bindings on the collapsed rectangle may break size updates; ensure that MinWidthOnCollapsed and MinCollapsedPortAreaHeight drive its layout instead of direct binding.
            // Set bindings

src/DynamoCoreWpf/Views/Core/AnnotationView.xaml.cs:3050

  • [nitpick] The same variable name optionalStyle is reused for both input and output port controls. Rename one to unconnectedStyle to avoid confusion.
            var optionalStyle = new Style(typeof(ItemsControl));

src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs:1409

  • New layout‐adjustment logic in UpdateLayoutForGroupExpansion should be covered by unit or integration tests to verify adjacent node repositioning.
        internal void UpdateLayoutForGroupExpansion()

src/DynamoCoreWpf/Views/Core/AnnotationView.xaml.cs:2904

  • [nitpick] Public‐facing private methods like CreateInputPortsGrid lack XML doc comments. Adding summaries will help maintainability.
        private Grid CreateInputPortsGrid()

src/DynamoCore/Graph/Annotations/AnnotationModel.cs:445

  • New public properties for port collapse should be documented in the API change log and considered for semantic versioning impact.
        private bool isOptionalInPortsCollapsed;

Comment thread src/DynamoCoreWpf/UI/Converters.cs Outdated
Comment thread src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml
Comment thread src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs Outdated
@zeusongit zeusongit requested a review from a team July 1, 2025 16:03
ivaylo-matov and others added 3 commits July 2, 2025 05:58

@jasonstratton jasonstratton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made one nitpick question and two other questions not about the code under review, but about the code pattern directed toward the Eidos team.

Since there is nothing outstanding aside from these questions and I'll approve the PR.

Comment thread src/DynamoCoreWpf/UI/Converters.cs
Comment thread src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
goto default;
case nameof(CollapseToMinSize):
description = Res.ResourceManager.GetString(nameof(Res.PreferencesViewCollapseToMinSizeDescription), System.Globalization.CultureInfo.InvariantCulture);
goto default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reddyashish , @zeusongit , @aparajit-pratap , this is not a question about this code in particular, but I wonder about this pattern.

The comment at the top of the switch indicates:
// C# does not support going through all cases when one of the case is true
While this is true, there still will be x string comparisons, if x is the number of case statements, if e.PropertyName does not match any of the cases or matches the last case statement.

I imagine the preferences model likely does not change often and it is not a huge list of case statements, but is this pattern repeated elsewhere? Something that is run in a loop? Multiple times?

Just thinking that this string comparison pattern could lead to some performance issues.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we use this same pattern for property changes on other elements.

@zeusongit

Copy link
Copy Markdown
Contributor


if (pinnedNode != null && helper.ReadGuid("pinnedNode") != Guid.Empty)
pinnedNode.GUID = helper.ReadGuid("pinnedNode");
PinnedNodeGuid = helper.ReadGuid("pinnedNode", Guid.Empty);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would still recommend wrapping this under try-catch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't ReadGuid() already handle failure case with Guild.Empty?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants